package com.fas.hehe.system.controller;

import java.util.Set;

import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authz.annotation.RequiresAuthentication;

import com.fas.core.BaseController;
import com.fas.core.constant.R;
import com.fas.core.plugin.jfinal.route.ControllerBind;
import com.fas.hehe.system.model.LoginUser;
import com.fas.hehe.system.service.ResourceService;
import com.fas.hehe.system.service.UserService;


@ControllerBind(controllerKey="/" )
public class IndexController extends BaseController {
	public UserService userService;
	public ResourceService resourceService;
	
	@RequiresAuthentication
	public void index() {
		LoginUser loginUser = (LoginUser)SecurityUtils.getSubject().getPrincipal();
		Set<String> permissions = userService.findPermissions(loginUser.getUserId());
		
		String contentPath = this.getRequest().getContextPath();
		String menuHtml = resourceService.buildMenus(R.Const.ROOT_RESID, contentPath,permissions);
		
		this.setAttr("loginUser", loginUser);
		this.setAttr("menuHtml", menuHtml);
		this.render("index.jsp");
	}

	public void welcome() {
	}
}
